<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>

</body>
<script>
	const Box = function(){
	
	};
	const obj = new Box();
	// 封装1
	function myInstanceof(L,R){
		L = L.__proto__;
		R = R.prototype;
		while (true){
			if(L === null) return false;
			if(L === R) return true;
			L = L.__proto__;
		}
	}
	// 封装2
	Object.prototype.instanceof = function(R){
		let L = this.__proto__;
		R = R.prototype;
		while (true){
			if(L === null) return false;
			if(L === R) return true;
			L = L.__proto__;
		}
	}
	
	
	console.log(myInstanceof(obj,Box), obj instanceof Box,obj.instanceof(Box));
	console.log(myInstanceof(obj,Object), obj instanceof Object,obj.instanceof(Object));
	const arr = [1,2,3];
	console.log(myInstanceof(arr,Array),arr instanceof Array,arr.instanceof(Array));
	console.log(myInstanceof(arr,Object),arr instanceof Object,arr.instanceof(Object));
</script>
</html>